/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package practicapoo.UI;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.Iterator;
import java.util.NoSuchElementException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import practicapoo.source.Camara;
import practicapoo.source.ListadoPeaje;
import practicapoo.source.Multa;
import practicapoo.source.RegistroInformacion;
import practicapoo.source.Vehiculo;

/**
 *
 * @author Pablo
 */
public class Principal extends javax.swing.JFrame {

    /**
     * Creates new form Principal
     */
    public Principal() {
        initComponents();
        this.setLocationRelativeTo(null);
        this.listado = new ListadoPeaje();


    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane2 = new javax.swing.JTabbedPane();
        jTabbedPane3 = new javax.swing.JTabbedPane();
        jPanel7 = new javax.swing.JPanel();
        jLabel14 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        matricu = new javax.swing.JTextField();
        jLabel17 = new javax.swing.JLabel();
        ConsultarHistorial = new javax.swing.JButton();
        ConsultarMultasPendientes = new javax.swing.JButton();
        jLabel16 = new javax.swing.JLabel();
        boton = new javax.swing.JButton();
        jPanel8 = new javax.swing.JPanel();
        jLabel15 = new javax.swing.JLabel();
        id1 = new javax.swing.JLabel();
        id2 = new javax.swing.JLabel();
        obtenerMulta = new javax.swing.JButton();
        idMulta = new javax.swing.JTextField();
        idMatricula = new javax.swing.JTextField();
        borrar = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        texto = new javax.swing.JTextPane();
        pagar = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        MultaExcesoVelocidad = new javax.swing.JButton();
        matriculam = new javax.swing.JTextField();
        jLabel12 = new javax.swing.JLabel();
        jLabel13 = new javax.swing.JLabel();
        velocidad1 = new javax.swing.JTextField();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jPanel4 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        carril = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        tama = new javax.swing.JTextField();
        AccesoVehiculo = new javax.swing.JButton();
        matri = new javax.swing.JTextField();
        calendario = new com.toedter.calendar.JCalendar();
        jLabel18 = new javax.swing.JLabel();
        jLabel19 = new javax.swing.JLabel();
        hora = new javax.swing.JComboBox();
        minuto = new javax.swing.JComboBox();
        jPanel5 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        matri2 = new javax.swing.JTextField();
        GenerarSalida = new javax.swing.JButton();
        jLabel10 = new javax.swing.JLabel();
        carri2 = new javax.swing.JComboBox();
        jLabel20 = new javax.swing.JLabel();
        jLabel21 = new javax.swing.JLabel();
        calenda = new com.toedter.calendar.JCalendar();
        horita1 = new javax.swing.JComboBox();
        minutito = new javax.swing.JComboBox();
        jPanel6 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        matri3 = new javax.swing.JTextField();
        ConsultarPeajes = new javax.swing.JButton();
        ConsultarMultaVM = new javax.swing.JButton();
        jLabel22 = new javax.swing.JLabel();
        jLabel23 = new javax.swing.JLabel();
        jLabel24 = new javax.swing.JLabel();
        listadoCoches = new javax.swing.JButton();
        cal1 = new com.toedter.calendar.JCalendar();
        cal2 = new com.toedter.calendar.JCalendar();
        jPanel1 = new javax.swing.JPanel();
        jLabel25 = new javax.swing.JLabel();
        cale1 = new com.toedter.calendar.JCalendar();
        cale2 = new com.toedter.calendar.JCalendar();
        jButton1 = new javax.swing.JButton();
        jLabel26 = new javax.swing.JLabel();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        CargarDatos = new javax.swing.JMenuItem();
        GuardarDatos = new javax.swing.JMenuItem();
        AcercaDe = new javax.swing.JMenu();
        AcercaDee = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Administración de Peaje");
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

        jLabel14.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel14.setText("Información sobre su vehículo");

        jLabel7.setText("Matrícula del vehículo:");

        matricu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matricuActionPerformed(evt);
            }
        });

        jLabel17.setText("Con ID");

        ConsultarHistorial.setText("Consultar historial de multas");
        ConsultarHistorial.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultarHistorialActionPerformed(evt);
            }
        });

        ConsultarMultasPendientes.setText("Consultar multas pendientes");
        ConsultarMultasPendientes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultarMultasPendientesActionPerformed(evt);
            }
        });

        jLabel16.setText("Sin ID");

        boton.setText("Historial ordenado de multas");
        boton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel16)
                    .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(boton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 177, Short.MAX_VALUE)
                        .addComponent(ConsultarMultasPendientes, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel14, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel7, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel17, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(ConsultarHistorial, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(matricu, javax.swing.GroupLayout.Alignment.LEADING)))
                .addContainerGap(447, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel7)
                .addGap(4, 4, 4)
                .addComponent(matricu, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel17)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ConsultarHistorial)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(ConsultarMultasPendientes)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel16)
                .addGap(4, 4, 4)
                .addComponent(boton)
                .addContainerGap(149, Short.MAX_VALUE))
        );

        jTabbedPane3.addTab("Información Multa", jPanel7);

        jLabel15.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel15.setText("Pagar multas");

        id1.setText("ID multa");

        id2.setText("Matrícula");

        obtenerMulta.setText("Obtener Multa");
        obtenerMulta.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                obtenerMultaActionPerformed(evt);
            }
        });

        borrar.setText("Borrar");
        borrar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                borrarActionPerformed(evt);
            }
        });

        jScrollPane1.setViewportView(texto);
        texto.setVisible(false);
        jScrollPane1.setVisible(false);

        pagar.setText("Pagar multa");
        pagar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pagarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8);
        jPanel8.setLayout(jPanel8Layout);
        jPanel8Layout.setHorizontalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel8Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addComponent(obtenerMulta, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(borrar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(pagar))
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel15)
                            .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                                    .addComponent(id2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(idMatricula, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel8Layout.createSequentialGroup()
                                    .addComponent(id1)
                                    .addGap(14, 14, 14)
                                    .addComponent(idMulta, javax.swing.GroupLayout.PREFERRED_SIZE, 53, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addGap(18, 18, 18)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(279, Short.MAX_VALUE))
        );
        jPanel8Layout.setVerticalGroup(
            jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel8Layout.createSequentialGroup()
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel8Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel15)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(id1)
                            .addComponent(idMulta, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(id2)
                            .addComponent(idMatricula, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(obtenerMulta)
                    .addComponent(borrar)
                    .addComponent(pagar))
                .addContainerGap(211, Short.MAX_VALUE))
        );

        borrar.setVisible(false);
        pagar.setVisible(false);

        jTabbedPane3.addTab("Pagar Multas", jPanel8);

        jTabbedPane2.addTab("Conductor", jTabbedPane3);

        jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel3.setText("General multa por exceso de velocidad");

        MultaExcesoVelocidad.setText("Multar");
        MultaExcesoVelocidad.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MultaExcesoVelocidadActionPerformed(evt);
            }
        });

        jLabel12.setText("Matrícula");

        jLabel13.setText("Velocidad");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel3)
                    .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(MultaExcesoVelocidad, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel3Layout.createSequentialGroup()
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jLabel13)
                                .addComponent(jLabel12))
                            .addGap(18, 18, 18)
                            .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(matriculam, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(velocidad1, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)))))
                .addContainerGap(410, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel3)
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(matriculam, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel13)
                    .addComponent(velocidad1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(27, 27, 27)
                .addComponent(MultaExcesoVelocidad)
                .addContainerGap(235, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Agentes de Autoridad", jPanel3);

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel1.setText("Introducir vehículo en el peaje:");

        jLabel4.setText("Carril");

        carril.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));

        jLabel5.setText("Matrícula");

        jLabel6.setText("Tamaño");

        tama.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tamaActionPerformed(evt);
            }
        });

        AccesoVehiculo.setText("Introducir Vehículo");
        AccesoVehiculo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AccesoVehiculoActionPerformed(evt);
            }
        });

        matri.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matriActionPerformed(evt);
            }
        });

        jLabel18.setText("Hora");

        jLabel19.setText("Minuto");

        hora.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23" }));

        minuto.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "59" }));

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel1)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6)
                                    .addComponent(jLabel4))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(carril, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                            .addComponent(matri, javax.swing.GroupLayout.DEFAULT_SIZE, 81, Short.MAX_VALUE)
                                            .addComponent(tama))
                                        .addGap(18, 18, 18)
                                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                            .addComponent(jLabel18, javax.swing.GroupLayout.Alignment.TRAILING)
                                            .addComponent(jLabel19, javax.swing.GroupLayout.Alignment.TRAILING))))))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(hora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(minuto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(38, 38, 38)
                        .addComponent(calendario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(AccesoVehiculo, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(163, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel4)
                            .addComponent(carril, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel5)
                            .addComponent(matri, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel18)
                            .addComponent(hora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(18, 18, 18)
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel6)
                            .addComponent(tama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel19)
                            .addComponent(minuto, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(calendario, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(AccesoVehiculo)
                .addContainerGap(176, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Introducir Vehículo", jPanel4);

        jLabel8.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel8.setText("Salida del peaje");

        jLabel9.setText("Matrícula");

        matri2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matri2ActionPerformed(evt);
            }
        });

        GenerarSalida.setText("Generar Ticket / Salida");
        GenerarSalida.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GenerarSalidaActionPerformed(evt);
            }
        });

        jLabel10.setText("Carril");

        carri2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4" }));
        carri2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                carri2ActionPerformed(evt);
            }
        });

        jLabel20.setText("Hora");

        jLabel21.setText("Minuto");

        horita1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", " " }));
        horita1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                horita1ActionPerformed(evt);
            }
        });

        minutito.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "0", "5", "10", "15", "20", "25", "30", "35", "40", "45", "50", "55", "59" }));

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(GenerarSalida, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel9)
                                    .addComponent(jLabel10))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(carri2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(64, 64, 64)
                                        .addComponent(jLabel20)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(horita1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel2Layout.createSequentialGroup()
                                        .addComponent(matri2, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addGap(18, 18, 18)
                                        .addComponent(jLabel21)
                                        .addGap(18, 18, 18)
                                        .addComponent(minutito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                            .addComponent(jLabel8))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 51, Short.MAX_VALUE)
                        .addComponent(calenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(161, 161, 161))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel8)
                        .addGap(16, 16, 16)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(carri2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel20)
                            .addComponent(horita1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel10))
                        .addGap(9, 9, 9)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel21)
                            .addComponent(minutito, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel9)
                            .addComponent(matri2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(calenda, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(GenerarSalida)
                .addContainerGap(176, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Registrar Salida", jPanel5);

        jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel2.setText("Datos individuales");

        jLabel11.setText("Matrícula del coche");

        matri3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                matri3ActionPerformed(evt);
            }
        });

        ConsultarPeajes.setText("Consultar Peajes");
        ConsultarPeajes.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultarPeajesActionPerformed(evt);
            }
        });

        ConsultarMultaVM.setText("Consultar Multas VM");
        ConsultarMultaVM.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ConsultarMultaVMActionPerformed(evt);
            }
        });

        jLabel22.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel22.setText("Datos generales");

        jLabel23.setText("Fecha inferior:");

        jLabel24.setText("Fecha superior:");

        listadoCoches.setText("Listado de coches");
        listadoCoches.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                listadoCochesActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel11)
                    .addComponent(matri3, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ConsultarPeajes, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(ConsultarMultaVM))
                .addGap(77, 77, 77)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel22)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(jLabel23)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel24)
                        .addGap(133, 133, 133))
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(cal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 29, Short.MAX_VALUE)
                        .addComponent(cal2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel6Layout.createSequentialGroup()
                        .addComponent(listadoCoches, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jLabel22))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jLabel23)
                    .addComponent(jLabel24))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel6Layout.createSequentialGroup()
                        .addComponent(matri3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ConsultarPeajes)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(ConsultarMultaVM))
                    .addComponent(cal1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(cal2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(listadoCoches)
                .addContainerGap(120, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Consultar Datos", jPanel6);

        jLabel25.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
        jLabel25.setText("Datos generales");

        jButton1.setText("Listado de multas");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel26.setText("Listado de multa dadas dos fechas");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                        .addComponent(jLabel25)
                        .addGroup(jPanel1Layout.createSequentialGroup()
                            .addComponent(cale1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(18, 18, 18)
                            .addComponent(cale2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jLabel26))
                .addContainerGap(238, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(cale2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel25)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel26)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(cale1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(jButton1)
                .addContainerGap(113, Short.MAX_VALUE))
        );

        jTabbedPane1.addTab("Historial de Multas", jPanel1);

        jTabbedPane2.addTab("Operario", jTabbedPane1);

        jMenu1.setText("Archivo");

        CargarDatos.setText("Cargar datos");
        CargarDatos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CargarDatosActionPerformed(evt);
            }
        });
        jMenu1.add(CargarDatos);

        GuardarDatos.setText("Guardar datos");
        GuardarDatos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                GuardarDatosActionPerformed(evt);
            }
        });
        jMenu1.add(GuardarDatos);

        jMenuBar1.add(jMenu1);

        AcercaDe.setText("Ver");
        AcercaDe.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AcercaDeActionPerformed(evt);
            }
        });

        AcercaDee.setText("Acerca de");
        AcercaDee.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AcercaDeeActionPerformed(evt);
            }
        });
        AcercaDe.add(AcercaDee);

        jMenuBar1.add(AcercaDe);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2)
        );

        getAccessibleContext().setAccessibleDescription("Práctica POO");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void GuardarDatosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GuardarDatosActionPerformed
        JFileChooser seleccionador = new JFileChooser();
        seleccionador.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int aux = seleccionador.showDialog(this, "Guardar en este directorio");
        if (aux == JFileChooser.APPROVE_OPTION) {
            File ruta = seleccionador.getSelectedFile();
            try {
                this.listado.guardar(ruta);
            } catch (IOException e) {
                JOptionPane.showMessageDialog(this, "No es posible guardar", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_GuardarDatosActionPerformed

    private void CargarDatosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CargarDatosActionPerformed
        JOptionPane.showMessageDialog(this, "Si carga datos borrará su actual sesión", "Atención", JOptionPane.INFORMATION_MESSAGE);
        JFileChooser seleccionador = new JFileChooser();
        seleccionador.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        int aux = seleccionador.showDialog(this, "Cargar desde este directorio");
        if (aux == JFileChooser.APPROVE_OPTION) {
            File ruta = seleccionador.getSelectedFile();
            try {
                try {
                    this.listado = new ListadoPeaje();
                    this.listado.cargar(ruta);
                } catch (ClassNotFoundException ex) {
                    Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
                }
            } catch (IOException e) {
                JOptionPane.showMessageDialog(this, "No es posible cargar", "Error", JOptionPane.ERROR_MESSAGE);
            }
        }
    }//GEN-LAST:event_CargarDatosActionPerformed

    private void AcercaDeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AcercaDeActionPerformed
    }//GEN-LAST:event_AcercaDeActionPerformed

    private void AcercaDeeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AcercaDeeActionPerformed
        AcercaDe acerca = new AcercaDe();
        acerca.setVisible(true);
        acerca.setLocationRelativeTo(null);
    }//GEN-LAST:event_AcercaDeeActionPerformed

    private void pagarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pagarActionPerformed
        this.listado.pagarMulta(Integer.parseInt(idMulta.getText()));
        if (this.listado.getMultados().get(Integer.parseInt(idMulta.getText())).isPagada() == true) {
            JOptionPane.showMessageDialog(this, "La multa ha sido abonada", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
        };
        texto.setVisible(false);
        pagar.setVisible(false);
        jScrollPane1.setVisible(false);
        texto.setText("");
        borrar.setVisible(false);
        id1.setVisible(true);
        id2.setVisible(true);
        idMatricula.setVisible(true);
        idMulta.setVisible(true);
        obtenerMulta.setVisible(true);
        idMatricula.setText("");
        idMulta.setText("");
    }//GEN-LAST:event_pagarActionPerformed

    private void borrarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_borrarActionPerformed
        texto.setVisible(false);
        pagar.setVisible(false);
        jScrollPane1.setVisible(false);
        texto.setText("");
        borrar.setVisible(false);
        id1.setVisible(true);
        id2.setVisible(true);
        idMatricula.setVisible(true);
        idMulta.setVisible(true);
        obtenerMulta.setVisible(true);
        idMatricula.setText("");
        idMulta.setText("");

    }//GEN-LAST:event_borrarActionPerformed

    private void obtenerMultaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_obtenerMultaActionPerformed
        try {
            String matricula = idMatricula.getText();
            matricula = matricula.trim();
            matricula = matricula.toUpperCase();
            int posicion = Integer.parseInt(idMulta.getText());

            if (this.listado.obtenerMulta(posicion, matricula)) {
                texto.setVisible(true);
                pagar.setVisible(true);
                jScrollPane1.setVisible(true);

                texto.setText("");
                texto.setText(this.listado.getMultados().get(posicion).toString());
                borrar.setVisible(true);

                id1.setVisible(false);
                id2.setVisible(false);
                idMatricula.setVisible(false);
                idMulta.setVisible(false);
                obtenerMulta.setVisible(false);
            } else {
                texto.setVisible(false);
                pagar.setVisible(false);
                jScrollPane1.setVisible(false);
                texto.setText("");
                borrar.setVisible(false);
                JOptionPane.showMessageDialog(this, "No hay multas sin pagar que se ajusten a los especificado");
            }

        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Error revise que los datos introducidos son correctos", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_obtenerMultaActionPerformed

    private void botonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonActionPerformed
        String entra = matricu.getText();
        entra = entra.trim();
        entra = entra.toUpperCase();
        ArrayList<Multa> lista = new ArrayList();
        lista = this.listado.ordenarListas(entra);

        ConsultaHistorialM informacion = new ConsultaHistorialM();
        ArrayList<String> lista2 = new ArrayList();
        lista2 = this.listado.aMultaToAString(lista);
        informacion.Consulta(lista2);
        if (lista.size() > 0) {
            informacion.setVisible(true);
            informacion.setLocationRelativeTo(null);
        } else {
            JOptionPane.showMessageDialog(this, "No hay información disponible", "Error", JOptionPane.INFORMATION_MESSAGE);
        }

        matricu.setText("");
    }//GEN-LAST:event_botonActionPerformed

    private void ConsultarMultasPendientesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultarMultasPendientesActionPerformed

        String matricula = matricu.getText();
        matricula = matricula.trim();
        matricula = matricula.toUpperCase();
        ArrayList<String> datos = new ArrayList();
        datos = this.listado.buscarMultaPendientes(matricula);

        ConsultaMPendientes consulta = new ConsultaMPendientes();

        consulta.Consulta(datos);
        if (datos.size() > 0) {
            consulta.setVisible(true);
            consulta.setLocationRelativeTo(null);
        } else {
            JOptionPane.showMessageDialog(this, "No hay información disponible", "Error", JOptionPane.INFORMATION_MESSAGE);
        }
        matricu.setText("");
    }//GEN-LAST:event_ConsultarMultasPendientesActionPerformed

    private void ConsultarHistorialActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultarHistorialActionPerformed
        String matricula = matricu.getText();
        matricula = matricula.trim();
        matricula = matricula.toUpperCase();
        ArrayList<String> datos = new ArrayList();
        datos = this.listado.buscarHistorialMultas(matricula);
        ConsultaHistorialM informacion = new ConsultaHistorialM();

        informacion.Consulta(datos);
        if (datos.size() > 0) {
            informacion.setVisible(true);
            informacion.setLocationRelativeTo(null);
        } else {
            JOptionPane.showMessageDialog(this, "No hay información disponible", "Error", JOptionPane.INFORMATION_MESSAGE);
        }

        matricu.setText("");
    }//GEN-LAST:event_ConsultarHistorialActionPerformed

    private void matricuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matricuActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_matricuActionPerformed

    private void ConsultarMultaVMActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultarMultaVMActionPerformed
        ArrayList<String> lista = new ArrayList();
        String matricula = matri3.getText();
        matricula = matricula.toUpperCase();
        matricula = matricula.trim();
        lista = this.listado.buscarMultaVM(matricula);
        ConsultaVMedia nConsulta = new ConsultaVMedia();
        nConsulta.Consulta(lista);
        if (lista.size() > 0) {
            nConsulta.setVisible(true);
            nConsulta.setLocationRelativeTo(null);
        } else {
            JOptionPane.showMessageDialog(this, "No hay información disponible", "Error", JOptionPane.INFORMATION_MESSAGE);
        }
    }//GEN-LAST:event_ConsultarMultaVMActionPerformed

    private void ConsultarPeajesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ConsultarPeajesActionPerformed

        String matricula = matri3.getText();
        matricula = matricula.trim();
        matricula = matricula.toUpperCase();
        ArrayList<String> datos = new ArrayList();
        datos = this.listado.historialVehiculo(matricula);
        if (datos.size() > 0) {
            ConsultarPeaje consulta = new ConsultarPeaje();
            consulta.introducirDatos(datos, matricula);
            consulta.setVisible(true);
            consulta.setLocationRelativeTo(null);
        } else {
            JOptionPane.showMessageDialog(this, "No existen datos que coincidan con lo solicitado", "Error", JOptionPane.INFORMATION_MESSAGE);
        }
        matri3.setText("");
    }//GEN-LAST:event_ConsultarPeajesActionPerformed

    private void matri3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matri3ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_matri3ActionPerformed

    private void carri2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_carri2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_carri2ActionPerformed

    private void GenerarSalidaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_GenerarSalidaActionPerformed

        GregorianCalendar var1 = new GregorianCalendar();
        var1 = (GregorianCalendar) calenda.getCalendar();
        long amodular = var1.getTimeInMillis();
        amodular = amodular % 86400000;
        long restar = var1.getTimeInMillis();
        restar = restar - amodular - 3600000 + 86400000;
        var1.setTimeInMillis(restar);



        long horatime = Long.parseLong(horita1.getSelectedItem().toString()) * 60 * 60 * 1000;
        long mintime = Long.parseLong(minutito.getSelectedItem().toString()) * 60 * 1000;
        mintime = mintime + horatime;
        restar = restar + mintime;
        var1.setTimeInMillis(restar);

        GregorianCalendar var2 = new GregorianCalendar();
        var2.getInstance();

        String matricula2 = matri2.getText();
        matricula2 = matricula2.toUpperCase();
        matricula2 = matricula2.trim();

        Camara camar = new Camara(Integer.parseInt((String) carri2.getModel().getSelectedItem()), true, 0, var1, false);

        RegistroInformacion registro = this.listado.obtenerRegistro(this.listado.getEnTransito(), matricula2);
        if (registro != null) {
            if (var1.getTimeInMillis() > registro.getCamaraEntrada().getFechahora().getTimeInMillis()) {
                if ((registro != null) && (registro.getVehiculo().getMatricula().equals(matricula2))) {
                    Ticket vTicket = new Ticket();
                    vTicket.entrada(registro);
                    vTicket.setVisible(true);
                    
                    this.listado.salidaPeaje(camar, registro);
                } else {
                    JOptionPane.showMessageDialog(this, "El vehículo no se encuentra en circulación", "Error", JOptionPane.INFORMATION_MESSAGE);
                }
                matri2.setText("");
            } else {
                JOptionPane.showMessageDialog(this, "La fecha no es válida, debe ser superior a la de entrada", "Error", JOptionPane.ERROR_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this, "No se encuentra en circulación", "Error", JOptionPane.INFORMATION_MESSAGE);
        }

        horita1.setSelectedIndex(0);
        minutito.setSelectedIndex(0);
        matri2.setText("");
    }//GEN-LAST:event_GenerarSalidaActionPerformed

    private void matri2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matri2ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_matri2ActionPerformed

    private void matriActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_matriActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_matriActionPerformed

    private void AccesoVehiculoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AccesoVehiculoActionPerformed
        try {
            String matricula = matri.getText();
            matricula = matricula.toUpperCase();
            matricula = matricula.trim();
            double tamaño = Double.parseDouble(tama.getText());
            int carri = Integer.parseInt(((String) carril.getModel().getSelectedItem()));
            Vehiculo nuevo = new Vehiculo(matricula, tamaño);

            GregorianCalendar var1 = new GregorianCalendar();
            var1 = (GregorianCalendar) calendario.getCalendar();
            long amodular = var1.getTimeInMillis();
            amodular = amodular % 86400000;
            long restar = var1.getTimeInMillis();
            restar = restar - amodular - 3600000 + 86400000;
            var1.setTimeInMillis(restar);

            long horatime = Long.parseLong(hora.getSelectedItem().toString()) * 60 * 60 * 1000;
            long mintime = Long.parseLong(minuto.getSelectedItem().toString()) * 60 * 1000;
            mintime = mintime + horatime;
            restar = restar + mintime;
            var1.setTimeInMillis(restar);

            GregorianCalendar var2 = new GregorianCalendar();
            var2.getInstance();
            long vari1 = var1.getTimeInMillis();

            long vari2 = var2.getTimeInMillis();
            if (vari1 > vari2) {
                Camara nueva = new Camara(carri, false, 0, var1, false);
                RegistroInformacion registro = new RegistroInformacion(nuevo, nueva);
                this.listado.entradaPeaje(nueva, nuevo);
                JOptionPane.showMessageDialog(this, "El vehículo se ha registrado", "Confirmación", JOptionPane.INFORMATION_MESSAGE);
            } else {
                JOptionPane.showMessageDialog(this, "Fecha/Hora no valida, debe ser igual o superior a la del sistema", "Error", JOptionPane.ERROR_MESSAGE);
            }
            matri.setText("");
            tama.setText("");
            hora.setSelectedIndex(0);
            minuto.setSelectedIndex(0);

        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Solo se admiten numeros decimales en el campo Tamaño."
                    + "\nRevisa que los campos están completados.", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_AccesoVehiculoActionPerformed

    private void tamaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tamaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tamaActionPerformed

    private void MultaExcesoVelocidadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MultaExcesoVelocidadActionPerformed
        try {
            String matrimulta = matriculam.getText();
            matrimulta = matrimulta.trim();
            matrimulta = matrimulta.toUpperCase();

            int velocidad = Integer.parseInt(velocidad1.getText());

            RegistroInformacion registro = null;
            registro = this.listado.obtenerRegistro(this.listado.getEnTransito(), matrimulta);

            if (registro != null) {
                Camara multaCamara = new Camara(1, false, velocidad, true);

                if (multaCamara.getVelocidad() > 120) {
                    Multa multita = new Multa(multaCamara.getVelocidad(), multaCamara.getFechahora(), registro.getVehiculo());
                    registro.setArrayMulta(multita);
                    JOptionPane.showMessageDialog(this, matrimulta + " ha sido multado \n" + this.listado.getEnTransito().get(this.listado.getEnTransito().indexOf(registro)).getArrayMulta().get(0));

                } else {
                    JOptionPane.showMessageDialog(this, "El vehículo no ha sido multado", "Informe", JOptionPane.INFORMATION_MESSAGE);
                }
            } else {
                JOptionPane.showMessageDialog(this, "No se encuentra el vehículo solicitado en circulación", "Error", JOptionPane.INFORMATION_MESSAGE);
            }
        } catch (NumberFormatException e) {
            JOptionPane.showMessageDialog(this, "Los valores de entrada no son correctos."
                    + "\nRevisa que los campos están completados correctamente.", "Error", JOptionPane.ERROR_MESSAGE);
        }
        velocidad1.setText("");
        matriculam.setText("");
    }//GEN-LAST:event_MultaExcesoVelocidadActionPerformed

    private void horita1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horita1ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_horita1ActionPerformed

    private void listadoCochesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_listadoCochesActionPerformed
        GregorianCalendar f1 = new GregorianCalendar();
        GregorianCalendar f2 = new GregorianCalendar();
        f1 = (GregorianCalendar) cal1.getCalendar();
        f2 = (GregorianCalendar) cal2.getCalendar();

        ArrayList<String> lista = new ArrayList();
        ListadoPeaje ordenar = new ListadoPeaje();

        ordenar = this.listado;
        Collections.sort(ordenar.getHistorico());
        lista = ordenar.historialPeaje(f1, f2);
        if ((f1.getTimeInMillis() < f2.getTimeInMillis())) {
            if (lista.size() > 0) {
                ConsultaHistorialPeaje ventana = new ConsultaHistorialPeaje();
                ventana.Consulta(lista, ordenar);
                ventana.setVisible(true);
                ventana.setLocationRelativeTo(null);
            } else {
                JOptionPane.showMessageDialog(this, "No hay datos disponibles", "Error", JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this, "El criterio de búsqueda no es válido", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_listadoCochesActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        GregorianCalendar f1 = new GregorianCalendar();
        GregorianCalendar f2 = new GregorianCalendar();
        f1 = (GregorianCalendar) cale1.getCalendar();
        f2 = (GregorianCalendar) cale2.getCalendar();

        ArrayList<String> lista = new ArrayList();
        ListadoPeaje ordenar = new ListadoPeaje();

        ordenar = this.listado;
        Collections.sort(ordenar.getMultados());
        lista = ordenar.historialMultas(f1, f2);
        if ((f1.getTimeInMillis() < f2.getTimeInMillis())) {
            if (lista.size() > 0) {
                CHistoricoMultas ventana = new CHistoricoMultas();
                ventana.Consulta(lista);
                ventana.setVisible(true);
                ventana.setLocationRelativeTo(null);
            } else {
                JOptionPane.showMessageDialog(this, "No hay datos disponibles", "Error", JOptionPane.INFORMATION_MESSAGE);
            }
        } else {
            JOptionPane.showMessageDialog(this, "El criterio de búsqueda no es válido", "Error", JOptionPane.ERROR_MESSAGE);
        }
    }//GEN-LAST:event_jButton1ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Principal.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Principal().setVisible(true);
                
            }
        });
    }
    private ListadoPeaje listado;
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton AccesoVehiculo;
    private javax.swing.JMenu AcercaDe;
    private javax.swing.JMenuItem AcercaDee;
    private javax.swing.JMenuItem CargarDatos;
    private javax.swing.JButton ConsultarHistorial;
    private javax.swing.JButton ConsultarMultaVM;
    private javax.swing.JButton ConsultarMultasPendientes;
    private javax.swing.JButton ConsultarPeajes;
    private javax.swing.JButton GenerarSalida;
    private javax.swing.JMenuItem GuardarDatos;
    private javax.swing.JButton MultaExcesoVelocidad;
    private javax.swing.JButton borrar;
    private javax.swing.JButton boton;
    private com.toedter.calendar.JCalendar cal1;
    private com.toedter.calendar.JCalendar cal2;
    private com.toedter.calendar.JCalendar cale1;
    private com.toedter.calendar.JCalendar cale2;
    private com.toedter.calendar.JCalendar calenda;
    private com.toedter.calendar.JCalendar calendario;
    private javax.swing.JComboBox carri2;
    private javax.swing.JComboBox carril;
    private javax.swing.JComboBox hora;
    private javax.swing.JComboBox horita1;
    private javax.swing.JLabel id1;
    private javax.swing.JLabel id2;
    private javax.swing.JTextField idMatricula;
    private javax.swing.JTextField idMulta;
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel19;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel20;
    private javax.swing.JLabel jLabel21;
    private javax.swing.JLabel jLabel22;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel25;
    private javax.swing.JLabel jLabel26;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JPanel jPanel8;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTabbedPane jTabbedPane3;
    private javax.swing.JButton listadoCoches;
    private javax.swing.JTextField matri;
    private javax.swing.JTextField matri2;
    private javax.swing.JTextField matri3;
    private javax.swing.JTextField matricu;
    private javax.swing.JTextField matriculam;
    private javax.swing.JComboBox minutito;
    private javax.swing.JComboBox minuto;
    private javax.swing.JButton obtenerMulta;
    private javax.swing.JButton pagar;
    private javax.swing.JTextField tama;
    private javax.swing.JTextPane texto;
    private javax.swing.JTextField velocidad1;
    // End of variables declaration//GEN-END:variables
}
